#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

int main()
{
	int year = 0;
	int month = 0;
	int day = 0;
	scanf("%d %d %d", &year, &month, &day);
	int dayOfMonth[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int theDay = 0;
	int i = 0;

	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
	{
		dayOfMonth[2] = 29;
	}

	for (i = 1; i < month; i++)
	{
		theDay += dayOfMonth[i];
	}
	theDay += day;

	printf("%d", theDay);

	return 0;
}